package com.example.demo.controller;

import com.example.demo.service.PersonalDashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/dashboard")
public class PersonalDashboardController {

    @Autowired
    private PersonalDashboardService personalDashboardService;

    /**
     * 获取个人数据看板
     */
    @GetMapping("/personal/{studentId}")
    public ResponseEntity<PersonalDashboardVO> getPersonalDashboard(@PathVariable Long studentId) {
        PersonalDashboardVO dashboard = personalDashboardService.getPersonalDashboard(studentId);
        return ResponseEntity.ok(dashboard);
    }

    /**
     * 获取个人课程进度
     */
    @GetMapping("/personal/{studentId}/course/{courseId}")
    public ResponseEntity<CourseProgressVO> getCourseProgress(
            @PathVariable Long studentId,
            @PathVariable Long courseId) {
        CourseProgressVO progress = personalDashboardService.getCourseProgress(studentId, courseId);
        return ResponseEntity.ok(progress);
    }
}